

function Star(hipparcosID, x, y, z, luminosity) {
    this.hipparcosID = hipparcosID;
    this.location = new Vector(x, y, z);
    this.luminosity = luminosity;
}

Star.prototype.render = function(p, width, height, context) {
    var squaredDistance = p.squaredLength();
    if (squaredDistance < 0.00000001 ||
	p.z < 0.00000001 ||
	p.z < p.y || p.z < p.x) {
        return;
    }
    var screenX = Math.round((p.x * width / p.z + width) / 2);
    var screenY = Math.round(height - (p.y * height / p.z + height) / 2);
    if (screenX < 0 || screenX > width || screenY < 0 || screenY > height) {
        return;
    }
    var brightness = 255 * 30 * 1000.0 * this.luminosity / squaredDistance;
    if (brightness <= 1) {
	return;
    }
    var b = Math.floor(Math.min(brightness, 255));
    var color = "rgb(" + b + "," + b + "," + b + ")";
    context.fillStyle = color;
    context.fillRect(screenX, screenY, 1, 1);
};
